(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.formDesign = factory());
}(this, (function () { 'use strict';

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    /* global Reflect, Promise */

    var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };

    function __extends(d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }

    var __assign = function() {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };

    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    }

    var BaseOption = /** @class */ (function () {
        function BaseOption() {
            this.id = "";
            this.label = "";
            this.width = "100%"; //控件宽
            this.height = "100%";
            this.labelWidth = 100; //文本
            this.defaultValue = ""; //默认值
            this.hidden = false; //是否隐藏
            this.disable = false; //是否禁用
        }
        return BaseOption;
    }());

    var InputOption = /** @class */ (function (_super) {
        __extends(InputOption, _super);
        function InputOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.placeholder = ""; //文本框内显示的占位文字
            _this.height = "25px";
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            return _this;
        }
        return InputOption;
    }(BaseOption));

    var OptionType = /** @class */ (function () {
        function OptionType(data) {
            this.name = data["name"];
            this.type = data["type"];
            this.default = data["default"];
            if (data["description"] != undefined) {
                this.description = data["description"];
            }
            if (data["options"] != undefined) {
                this.options = data["options"];
            }
            if (data["hidden"] != undefined) {
                this.hidden = data["hidden"];
            }
        }
        return OptionType;
    }());

    var AllConfig = /** @class */ (function () {
        function AllConfig() {
            // id:OptionType=new OptionType({name:"ID",type:"text",default:"",hidden:true});
            // type:OptionType=new OptionType({name:"type",type:"text",default:"",hidden:true});
            this.label = new OptionType({ name: '标题', type: 'text', default: '单行文本' });
            this.width = new OptionType({ name: "宽度", type: "text", default: "100%" });
            this.height = new OptionType({ name: "高度", type: "text", default: "100%" });
            this.space = new OptionType({ name: "列间隔", type: "text", default: "0" });
            this.columns = new OptionType({ name: "列配置", type: "columns", default: [], description: "栅格化布局，将屏幕12等分,设置用逗号隔开" });
            this.placeholder = new OptionType({ name: "占位内容", type: "text", default: "" });
            this.isSearch = new OptionType({ name: "开启搜索", type: "checkbox", default: false });
            this.format = new OptionType({ name: '日期格式', type: 'text', default: 'yyyy-MM-dd' });
            this.labelWidth = new OptionType({ name: "文本宽度", type: "number", default: 200 });
            this.defaultValue = new OptionType({ name: "默认值", type: "text", default: "", description: "多个值用逗号隔开,#devuser#可以替换为当前登陆用户" });
            this.options = new OptionType({ name: "选项", type: "singleitem", default: "", description: "配置格式为:value#label/value2#label2" });
            this.action = new OptionType({ name: '上传地址', type: 'text', default: '' });
            this.multiple = new OptionType({ name: "多文件", type: "checkbox", default: false });
            this.field = new OptionType({ name: "文件字段名", type: "text", default: "" });
            this.filesize = new OptionType({ name: "文件大小", type: "text", default: "", description: "最大可允许上传,单位kb,0（即不限制）" });
            this.acceptfile = new OptionType({ name: "文件类型", type: "text", default: "", description: "可选值有：images（图片）、file（所有文件）、video（视频）、audio（音频）" });
            this.inlinecss = new OptionType({ name: "行样式", type: "text", default: '' });
            this.itemcss = new OptionType({ name: "选项样式", type: "text", default: '' });
            this.hidden = new OptionType({ name: "隐藏", type: "checkbox", default: false });
            this.inline = new OptionType({ name: "行内元素", type: "checkbox", default: false });
            this.disable = new OptionType({ name: "禁用", type: "checkbox", default: false });
            this.required = new OptionType({ name: "必填", type: "checkbox", default: false });
            this.requiredMessage = new OptionType({ name: "必填提示", type: "text", default: "" });
        }
        return AllConfig;
    }());

    var Input = /** @class */ (function () {
        function Input() {
            this._option = new InputOption();
            this._config = new AllConfig();
        }
        Input.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            this._htmlelement = element;
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px;\">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"width:" + this._option.width + ";height:" + this._option.height + ";\"> \n           <input  type=\"text\" autocomplete=\"off\" class=\"dlong_input \"\n             \n              id=\"" + this._option.id + "\" \n              name=\"" + this._option.id + "\"\n              " + (this._option.disable ? 'disabled="disabled"' : "") + "\n              \n              placeholder=\"" + this._option.placeholder + "\"\n              />\n              </div>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._element = element.querySelector("input");
            this.setValue(this._option.defaultValue);
        };
        Input.prototype.setValue = function (value) {
            this._element.value = value;
        };
        Input.prototype.getValue = function () {
            return this._element.value;
        };
        Input.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Input.prototype.getConfig = function () {
            return this._config;
        };
        Input.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Input.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Input;
    }());

    var TextAreaOption = /** @class */ (function (_super) {
        __extends(TextAreaOption, _super);
        function TextAreaOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.placeholder = ""; //文本框内显示的占位文字
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            return _this;
        }
        return TextAreaOption;
    }(BaseOption));

    var TextArea = /** @class */ (function () {
        function TextArea() {
            this._option = new TextAreaOption();
            this._config = new AllConfig();
        }
        TextArea.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            this._htmlelement = element;
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px\">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"width:" + this._option.width + ";height:" + this._option.height + " \"> \n           <textarea autocomplete=\"off\" class=\"dlong_textarea\" type=\"text\" \n              id=\"" + this._option.id + "\" \n              name=\"" + this._option.id + "\"\n              " + (this._option.disable ? 'disabled="disabled"' : "") + "\n              placeholder=\"" + this._option.placeholder + "\"\n              >\n            \n              </textarea>\n              </div>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._element = element.querySelector("textarea");
            this.setValue(this._option.defaultValue);
        };
        TextArea.prototype.setValue = function (value) {
            this._element.value = value;
        };
        TextArea.prototype.getValue = function () {
            return this._element.value;
        };
        TextArea.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        TextArea.prototype.getConfig = function () {
            return this._config;
        };
        TextArea.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        TextArea.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return TextArea;
    }());

    var LabelOption = /** @class */ (function (_super) {
        __extends(LabelOption, _super);
        function LabelOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.defaultValue = "This is a text";
            return _this;
        }
        return LabelOption;
    }(BaseOption));

    var Label = /** @class */ (function () {
        function Label() {
            this._option = new LabelOption();
            this._config = new AllConfig();
        }
        Label.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            this._htmlelement = element;
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "\"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n            <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px\">\n            \n            <div style=\"width:" + this._option.width + ";height:" + this._option.height + " \"> \n            <span class=\"dlong_span\"\n              id=\"" + this._option.id + "\" \n              name=\"" + this._option.id + "\"\n              >\n              </span>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._element = element.querySelector("span");
            this.setValue(this._option.defaultValue);
        };
        Label.prototype.setValue = function (value) {
            this._element.innerHTML = value;
        };
        Label.prototype.getValue = function () {
            return this._element.innerHTML;
        };
        Label.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Label.prototype.getConfig = function () {
            return this._config;
        };
        Label.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Label.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Label;
    }());

    var RadioOption = /** @class */ (function (_super) {
        __extends(RadioOption, _super);
        function RadioOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            _this.inline = true;
            _this.defaultValue = "Option1";
            _this.inlinecss = "";
            _this.itemcss = "";
            _this.options = [
                {
                    "value": "Option1",
                    "label": "Option 1"
                },
                {
                    "value": "Option2",
                    "label": "Option 2"
                },
                {
                    "value": "Option3",
                    "label": "Option 3"
                }
            ];
            return _this;
        }
        return RadioOption;
    }(BaseOption));

    var Radio = /** @class */ (function () {
        function Radio() {
            this._option = new RadioOption();
            this._config = new AllConfig();
        }
        Radio.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var optionstr = "";
            for (var i = 0; i < this._option.options.length; i++) {
                var item = this._option.options[i];
                optionstr += "<label class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"display:" + (this._option.inline ? "inline-block" : "block") + ";" + this._option.itemcss + "\">\n                <span class=\"dlong_radio_input\">\n                <input type=\"radio\"\n                " + (this._option.disable ? 'disabled="disabled"' : "") + "\n                name=\"" + this._option.id + "\" value=\"" + item["value"] + "\">\n                </span>\n                 <span class=\"dlong_radio_label\">\n                 " + item["label"] + "\n                 </span>\n                 </label>";
            }
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\" margin-left:" + this._option.labelWidth + "px; \">\n           <div style=\"width:" + this._option.width + ";" + this._option.inlinecss + " \">\n          \n           " + optionstr + "\n          </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._htmlelement = element;
            this.setValue(this._option.defaultValue);
        };
        Radio.prototype.setValue = function (value) {
            var listradio = this._htmlelement.querySelectorAll("input[value='" + value + "']");
            if (listradio.length > 0) {
                listradio[0].setAttribute("checked", "true");
            }
        };
        Radio.prototype.getValue = function () {
            var el = this._htmlelement.querySelector("input:checked");
            if (el)
                return el.value;
            else {
                return "";
            }
        };
        Radio.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Radio.prototype.getConfig = function () {
            return this._config;
        };
        Radio.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Radio.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Radio;
    }());

    var Checkbox = /** @class */ (function () {
        function Checkbox() {
            this._option = new RadioOption();
            this._config = new AllConfig();
        }
        Checkbox.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var optionstr = "";
            for (var i = 0; i < this._option.options.length; i++) {
                var item = this._option.options[i];
                optionstr += "<div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"display:" + (this._option.inline ? "inline-block;" : "block") + ";" + this._option.itemcss + "\">\n                <span class=\"dlong_radio_input\">\n                <input  \n                type=\"checkbox\" \n                name=\"" + this._option.id + "\" \n                value=\"" + item["value"] + "\"\n                " + (this._option.disable ? 'disabled="disabled"' : "") + "\n                >\n                </span>\n                 <span class=\"dlong_radio_label\">\n                 " + item["label"] + "\n                 </span>\n                 </div>";
            }
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\" margin-left:" + this._option.labelWidth + "px;\">\n           <div style=\"display:" + (this._option.inline ? "inline-block" : "block") + ";width:" + this._option.width + ";" + this._option.inlinecss + " \">\n          \n            " + optionstr + "\n           </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._htmlelement = element;
            this.setValue(this._option.defaultValue);
        };
        Checkbox.prototype.setValue = function (value) {
            var list = this._htmlelement.querySelectorAll("input:checked");
            for (var i = 0; i < list.length; i++) {
                list[i].removeAttribute("checked");
            }
            var valuelist = value.split(",");
            for (var i = 0; i < valuelist.length; i++) {
                var listradio = this._htmlelement.querySelector("input[value='" + valuelist[i] + "']");
                if (listradio) {
                    listradio.setAttribute("checked", "true");
                }
            }
        };
        Checkbox.prototype.getValue = function () {
            var listradio = this._htmlelement.querySelectorAll("input:checked");
            var checklist = [];
            if (listradio.length > 0) {
                for (var i = 0; i < listradio.length; i++) {
                    checklist.push(listradio[i].value);
                }
                return checklist.join(",");
            }
            else {
                return "";
            }
        };
        Checkbox.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Checkbox.prototype.getConfig = function () {
            return this._config;
        };
        Checkbox.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Checkbox.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Checkbox;
    }());

    var SelectOption = /** @class */ (function (_super) {
        __extends(SelectOption, _super);
        function SelectOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            _this.height = "25px";
            _this.inline = true;
            _this.isSearch = false;
            _this.defaultValue = "Option1";
            _this.options = [
                {
                    "value": "Option1",
                    "label": "Option 1"
                },
                {
                    "value": "Option2",
                    "label": "Option 2"
                },
                {
                    "value": "Option3",
                    "label": "Option 3"
                }
            ];
            return _this;
        }
        return SelectOption;
    }(BaseOption));

    var Select = /** @class */ (function () {
        function Select() {
            this._option = new SelectOption();
            this._config = new AllConfig();
        }
        Select.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var optionstr = "";
            for (var i = 0; i < this._option.options.length; i++) {
                var item = this._option.options[i];
                optionstr += "<option  value=\"" + item["value"] + "\">" + item["label"] + "</option>";
            }
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "   " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\" margin-left:" + this._option.labelWidth + "px; \">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"width:" + this._option.width + ";height:" + this._option.height + "; \"> \n           <select \n           id=\"" + this._option.id + "\" \n           lay-search=\"true\"  " + (this._option.disable ? 'disabled="disabled"' : "") + " \n           class=\"dlong_select " + (this._option.isSearch ? "dlong_hide" : "") + "\">\n            " + optionstr + "\n            </select>\n            </div>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._htmlelement = element;
            this.setValue(this._option.defaultValue);
            if (this._option.isSearch) {
                this.select();
            }
        };
        Select.prototype.setValue = function (value) {
            var sel = this._htmlelement.querySelector("select option[value='" + value + "']");
            if (sel) {
                sel.selected = true;
            }
        };
        Select.prototype.getValue = function () {
            var el = this._htmlelement.querySelector("select");
            if (el) {
                return el.options[el.selectedIndex].value;
            }
            else {
                return "";
            }
        };
        Select.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Select.prototype.getConfig = function () {
            return this._config;
        };
        Select.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Select.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        //下拉选择框
        Select.prototype.select = function () {
            var that = this;
            var $ = layui.$, $dom = $(document), $win = $(window), HIDE = 'dlong_hide', THIS = 'dlong_this', DISABLED = 'dlong_disable';
            var TIPS = '请选择', CLASS = 'dlong_form_select', TITLE = 'dlong_select_title', NONE = 'dlong_select_none', initValue = '', thatInput, selects = $(this._htmlelement).find('select')
            //隐藏 select
            , hide = function (e, clear) {
                if (!$(e.target).parent().hasClass(TITLE) || clear) {
                    $('.' + CLASS).removeClass(CLASS + 'ed ' + CLASS + 'up');
                    thatInput && initValue && thatInput.val(initValue);
                }
                thatInput = null;
            }
            //各种事件
            , events = function (reElem, disabled, isSearch) {
                var select = $(this), title = reElem.find('.' + TITLE), input = title.find('input'), dl = reElem.find('dl'), dds = dl.children('dd'), index = this.selectedIndex //当前选中的索引
                , nearElem; //select 组件当前选中的附近元素，用于辅助快捷键功能
                if (disabled)
                    return;
                //展开下拉
                var showDown = function () {
                    var top = reElem.offset().top + reElem.outerHeight() + 5 - $win.scrollTop(), dlHeight = dl.outerHeight();
                    index = select[0].selectedIndex; //获取最新的 selectedIndex
                    reElem.addClass(CLASS + 'ed');
                    dds.removeClass(HIDE);
                    nearElem = null;
                    //初始选中样式
                    dds.eq(index).addClass(THIS).siblings().removeClass(THIS);
                    //上下定位识别
                    if (top + dlHeight > $win.height() && top >= dlHeight) {
                        reElem.addClass(CLASS + 'up');
                    }
                    followScroll();
                }
                //隐藏下拉
                , hideDown = function (choose) {
                    reElem.removeClass(CLASS + 'ed ' + CLASS + 'up');
                    input.blur();
                    nearElem = null;
                    if (choose)
                        return;
                    notOption(input.val(), function (none) {
                        var selectedIndex = select[0].selectedIndex;
                        //未查询到相关值
                        if (none) {
                            initValue = $(select[0].options[selectedIndex]).html(); //重新获得初始选中值
                            //如果是第一项，且文本值等于 placeholder，则清空初始值
                            if (selectedIndex === 0 && initValue === input.attr('placeholder')) {
                                initValue = '';
                            }
                            //如果有选中值，则将输入框纠正为该值。否则清空输入框
                            input.val(initValue || '');
                        }
                    }, null);
                }
                //定位下拉滚动条
                , followScroll = function () {
                    var thisDd = dl.children('dd.' + THIS);
                    if (!thisDd[0])
                        return;
                    var posTop = thisDd.position().top, dlHeight = dl.height(), ddHeight = thisDd.height();
                    //若选中元素在滚动条不可见底部
                    if (posTop > dlHeight) {
                        dl.scrollTop(posTop + dl.scrollTop() - dlHeight + ddHeight - 5);
                    }
                    //若选择玄素在滚动条不可见顶部
                    if (posTop < 0) {
                        dl.scrollTop(posTop + dl.scrollTop() - 5);
                    }
                };
                //点击标题区域
                title.on('click', function (e) {
                    reElem.hasClass(CLASS + 'ed') ? (hideDown(null)) : (hide(e, true),
                        showDown());
                    dl.find('.' + NONE).remove();
                });
                //点击箭头获取焦点
                title.find('.layui-edge').on('click', function () {
                    input.focus();
                });
                //select 中 input 键盘事件
                input.on('keyup', function (e) {
                    var keyCode = e.keyCode;
                    //Tab键展开
                    if (keyCode === 9) {
                        showDown();
                    }
                }).on('keydown', function (e) {
                    var keyCode = e.keyCode;
                    //Tab键隐藏
                    if (keyCode === 9) {
                        hideDown(null);
                    }
                    //标注 dd 的选中状态
                    var setThisDd = function (prevNext, thisElem1) {
                        var nearDd, cacheNearElem;
                        e.preventDefault();
                        //得到当前队列元素  
                        var thisElem = function () {
                            var thisDd = dl.children('dd.' + THIS);
                            //如果是搜索状态，且按 Down 键，且当前可视 dd 元素在选中元素之前，
                            //则将当前可视 dd 元素的上一个元素作为虚拟的当前选中元素，以保证递归不中断
                            if (dl.children('dd.' + HIDE)[0] && prevNext === 'next') {
                                var showDd = dl.children('dd:not(.' + HIDE + ',.' + DISABLED + ')'), firstIndex = showDd.eq(0).index();
                                if (firstIndex >= 0 && firstIndex < thisDd.index() && !showDd.hasClass(THIS)) {
                                    return showDd.eq(0).prev()[0] ? showDd.eq(0).prev() : dl.children(':last');
                                }
                            }
                            if (thisElem1 && thisElem1[0]) {
                                return thisElem1;
                            }
                            if (nearElem && nearElem[0]) {
                                return nearElem;
                            }
                            return thisDd;
                            //return dds.eq(index);
                        }();
                        cacheNearElem = thisElem[prevNext](); //当前元素的附近元素
                        nearDd = thisElem[prevNext]('dd:not(.' + HIDE + ')'); //当前可视元素的 dd 元素
                        //如果附近的元素不存在，则停止执行，并清空 nearElem
                        if (!cacheNearElem[0])
                            return nearElem = null;
                        //记录附近的元素，让其成为下一个当前元素
                        nearElem = thisElem[prevNext]();
                        //如果附近不是 dd ，或者附近的 dd 元素是禁用状态，则进入递归查找
                        if ((!nearDd[0] || nearDd.hasClass(DISABLED)) && nearElem[0]) {
                            return setThisDd(prevNext, nearElem);
                        }
                        nearDd.addClass(THIS).siblings().removeClass(THIS); //标注样式
                        followScroll(); //定位滚动条
                    };
                    if (keyCode === 38)
                        setThisDd('prev', null); //Up 键
                    if (keyCode === 40)
                        setThisDd('next', null); //Down 键
                    //Enter 键
                    if (keyCode === 13) {
                        e.preventDefault();
                        dl.children('dd.' + THIS).trigger('click');
                    }
                });
                //检测值是否不属于 select 项
                var notOption = function (value, callback, origin) {
                    var num = 0;
                    layui.each(dds, function () {
                        var othis = $(this), text = othis.text(), dlvalue = othis.attr("lay-value"), not = (text.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) === -1 && dlvalue.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) === -1);
                        if (value === '' || (origin === 'blur') ? value !== text : not)
                            num++;
                        origin === 'keyup' && othis[not ? 'addClass' : 'removeClass'](HIDE);
                    });
                    var none = num === dds.length;
                    return callback(none), none;
                };
                //搜索匹配
                var search = function (e) {
                    var value = this.value, keyCode = e.keyCode;
                    if (keyCode === 9 || keyCode === 13
                        || keyCode === 37 || keyCode === 38
                        || keyCode === 39 || keyCode === 40) {
                        return false;
                    }
                    notOption(value, function (none) {
                        if (none) {
                            dl.find('.' + NONE)[0] || dl.append('<p class="' + NONE + '">无匹配项</p>');
                        }
                        else {
                            dl.find('.' + NONE).remove();
                        }
                    }, 'keyup');
                    if (value === '') {
                        dl.find('.' + NONE).remove();
                    }
                    followScroll(); //定位滚动条
                };
                if (isSearch) {
                    input.on('keyup', search).on('blur', function (e) {
                        var selectedIndex = select[0].selectedIndex;
                        thatInput = input; //当前的 select 中的 input 元素
                        initValue = $(select[0].options[selectedIndex]).text(); //重新获得初始选中值
                        //如果是第一项，且文本值等于 placeholder，则清空初始值
                        if (selectedIndex === 0 && initValue === input.attr('placeholder')) {
                            initValue = '';
                        }
                        setTimeout(function () {
                            notOption(input.val(), function (none) {
                                initValue || input.val(''); //none && !initValue
                            }, 'blur');
                        }, 200);
                    });
                }
                //选择
                dds.on('click', function () {
                    var othis = $(this), value = othis.attr('lay-value');
                    var filter = select.attr('lay-filter'); //获取过滤器
                    if (othis.hasClass(DISABLED))
                        return false;
                    if (othis.hasClass('dlong_select_tips')) {
                        input.val('');
                    }
                    else {
                        input.val(othis.text());
                        othis.addClass(THIS);
                    }
                    othis.siblings().removeClass(THIS);
                    select.val(value).removeClass('layui-form-danger');
                    hideDown(true);
                    return false;
                });
                reElem.find('dl>dt').on('click', function (e) {
                    return false;
                });
                $(document).off('click', hide).on('click', hide); //点击其它元素关闭 select
            };
            selects.each(function (index, select) {
                var othis = $(this), hasRender = othis.next('.' + CLASS), disabled = this.disabled, value = select.value, selected = $(select.options[select.selectedIndex]) //获取当前选中项
                , optionsFirst = select.options[0];
                if (typeof othis.attr('lay-ignore') === 'string')
                    return othis.show();
                var isSearch = typeof othis.attr('lay-search') === 'string', placeholder = optionsFirst ? (optionsFirst.value ? TIPS : (optionsFirst.innerHTML || TIPS)) : TIPS;
                //替代元素
                var reElem = $(['<div class="' + (isSearch ? '' : 'dlong_unselect ') + CLASS,
                    (disabled ? ' dlong_select_disabled' : '') + '">',
                    '<div  style="width:' + that._option.width + ';height:' + that._option.height + '; " class="' + (that._option.disable ? "dlong_disable" : "") + TITLE + '">',
                    ('<input type="text" placeholder="' + placeholder + '" '
                        + ('value="' + (value ? selected.text() : '') + '"') //默认值
                        + ((!disabled && isSearch) ? '' : ' readonly') //是否开启搜索
                        + ' class="dlong_input'
                        + (isSearch ? '' : ' dlong_unselect')
                        + (disabled ? (' ' + DISABLED) : '') + '">') //禁用状态
                    ,
                    '<i class="dlong_edge"></i></div>',
                    '<dl class="dlong_anim dlong_anim_upbit' + (othis.find('optgroup')[0] ? ' layui-select-group' : '') + '">', function (options) {
                        var arr = [];
                        layui.each(options, function (index, item) {
                            if (index === 0 && !item.value) {
                                arr.push('<dd lay-value="" class="dlong_select_tips">' + (item.innerHTML || TIPS) + '</dd>');
                            }
                            else if (item.tagName.toLowerCase() === 'optgroup') {
                                arr.push('<dt>' + item.label + '</dt>');
                            }
                            else {
                                arr.push('<dd lay-value="' + item.value + '" class="' + (value === item.value ? THIS : '') + (item.disabled ? (' ' + DISABLED) : '') + '">' + item.innerHTML + '</dd>');
                            }
                        });
                        arr.length === 0 && arr.push('<dd lay-value="" class="' + DISABLED + '">没有选项</dd>');
                        return arr.join('');
                    }(othis.find('*')) + '</dl>', '</div>'].join(''));
                hasRender[0] && hasRender.remove(); //如果已经渲染，则Rerender
                othis.after(reElem);
                events.call(this, reElem, disabled, isSearch);
            });
        };
        return Select;
    }());

    var DateOption = /** @class */ (function (_super) {
        __extends(DateOption, _super);
        function DateOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.placeholder = "";
            _this.height = "25px"; //文本框内显示的占位文字
            _this.format = "yyyy-MM-dd"; //日期格式化
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            return _this;
        }
        return DateOption;
    }(BaseOption));

    var Date = /** @class */ (function () {
        function Date() {
            this._option = new DateOption();
            this._config = new AllConfig();
        }
        Date.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            this._htmlelement = element;
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px; \">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"width:" + this._option.width + ";height:" + this._option.height + "; \"> \n           <input  type=\"text\" autocomplete=\"off\" class=\"dlong_input\"\n             \n              id=\"" + this._option.id + "\" \n              name=\"" + this._option.id + "\"\n              \n              " + (this._option.disable ? 'disabled="disabled"' : "") + "\n\n              placeholder=\"" + this._option.placeholder + "\"\n              />\n              </div>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._element = element.querySelector("input");
            this.setValue(this._option.defaultValue);
            layui.laydate.render({
                elem: this._element,
                format: this._option.format,
                type: this._option.format.length > 12 ? "datetime" : "date"
            });
        };
        Date.prototype.setValue = function (value) {
            this._element.value = value;
        };
        Date.prototype.getValue = function () {
            return this._element.value;
        };
        Date.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Date.prototype.getConfig = function () {
            return this._config;
        };
        Date.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Date.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Date;
    }());

    var FileUploadOption = /** @class */ (function (_super) {
        __extends(FileUploadOption, _super);
        function FileUploadOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.action = "/DevCommFileUpload30"; //上传地址
            _this.multiple = false; //多个文件上传
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            _this.field = "uploadfiles"; //设定文件域的字段名
            _this.filesize = 0; //设置文件最大可允许上传的大小
            _this.acceptfile = "images"; //指定允许上传时校验的文件类型
            return _this;
        }
        return FileUploadOption;
    }(BaseOption));

    var FileUpload = /** @class */ (function () {
        function FileUpload() {
            this._fileurl = [];
            this._option = new FileUploadOption();
            this._config = new AllConfig();
        }
        FileUpload.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px;\">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\"  style=\"width:" + this._option.width + " \"> \n           <button type=\"button\" class=\"dlong_fileupload\"\n           " + (this._option.disable ? 'disabled="disabled"' : "") + "\n           id=\"" + this._option.id + "\">\n            \u70B9\u51FB\u4E0A\u4F20\n            </button>\n            </div>\n            <ul class=\"dlong_fileupload_list\">\n              \n            </ul>\n\n              </div>\n\n            ";
            element.innerHTML = html;
            this._htmlelement = element;
            this._element = element.querySelector("button");
            this.setValue(this._option.defaultValue);
            var that = this;
            layui.upload.render({
                elem: this._element,
                url: this._option.action,
                field: this._option.field,
                multiple: this._option.multiple,
                before: function () {
                    that._element.innerText = "上传中...";
                    that._element.disabled = true;
                    if (!that._option.multiple) {
                        that._fileurl = [];
                    }
                },
                done: function (res, index, upload) {
                    that._element.innerText = "点击上传";
                    that._element.disabled = false;
                    if (res.success) {
                        var value = res.filenamesrcs;
                        var filenamesOrg = res.filenamesOrg;
                        var valuelist = (value instanceof Array) ? value : value.split(",");
                        var filenamelist = (filenamesOrg instanceof Array) ? filenamesOrg : filenamesOrg.split(",");
                        for (var i = 0; i < valuelist.length; i++) {
                            var valuelistElement = valuelist[i];
                            valuelist[i]= valuelist[i]+"_@@_"+filenamelist[i];
                        }
                        if (that._option.multiple) {
                            that._fileurl = __spreadArrays(valuelist, that._fileurl);
                        }
                        else {
                            that._fileurl = valuelist;
                        }
                        that.setValue(that._fileurl);
                    }
                    else {
                        that.setValue({ error: res.msg });
                    }
                },
                error: function (index, upload) {
                    that._element.innerText = "点击上传";
                    that._element.disabled = false;
                    that.setValue({ error: "上传失败" });
                },
                accept: this._option.acceptfile //允许上传的文件类型
                ,
                size: this._option.filesize //最大允许上传的文件大小
                //,……
            });
        };
        FileUpload.prototype.setValue = function (value) {
            var html = "";
            if (!value) {
                this._fileurl = [];
                return;
            }
            if (value.error) {
                html += "<li class=\"dlong_fileupload_list_item\">\n                <span style=\"color:red\">" + value.error + "</span>\n                </li>";
            }
            else {
                var valuelist = (value instanceof Array) ? value : value.split(",");
                this._fileurl = valuelist;
            }
            for (var i = 0; i < this._fileurl.length; i++) {
                var hrefUrlOrg= this._fileurl[i];
                var hrefUrl=hrefUrlOrg;
                var mc = hrefUrl.substr(hrefUrl.lastIndexOf("/") + 1);
                if(hrefUrlOrg.lastIndexOf("_@@_")>-1){
                    hrefUrl=hrefUrlOrg.substr(0,hrefUrlOrg.lastIndexOf("_@@_"));
                    mc=hrefUrlOrg.substr(hrefUrlOrg.lastIndexOf("_@@_")+4);
                }
                html += "<li class=\"dlong_fileupload_list_item\">\n                <a href=\"" + hrefUrl + "\" target='_blank'><i  class=\"layui-icon layui-icon-file\"></i> " + mc + "</a>\n                <i class=\"layui-icon layui-icon-close dl_filedel\"></i>\n                </li>";
                //this._fileurl.push(valuelist[i]);
            }
            var flist = this._htmlelement.querySelector(".dlong_fileupload_list");
            flist.innerHTML = html;
            var itemlist = Array.prototype.slice.call(this._htmlelement.querySelectorAll(".dl_filedel"));
            var that = this;
            //监听删除
            itemlist.forEach(function (item, ind) {
                item.removeEventListener("click", function () {
                    that.deleteFile(ind);
                });
            });
            itemlist.forEach(function (item, ind) {
                item.addEventListener("click", function () {
                    that.deleteFile(ind);
                });
            });
        };
        FileUpload.prototype.deleteFile = function (index) {
            this._fileurl.splice(index, 1);
            this.setValue(this._fileurl);
        };
        FileUpload.prototype.getValue = function () {
            return this._fileurl.join(",");
        };
        FileUpload.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        FileUpload.prototype.getConfig = function () {
            return this._config;
        };
        FileUpload.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        FileUpload.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return FileUpload;
    }());

    var EditorOption = /** @class */ (function (_super) {
        __extends(EditorOption, _super);
        function EditorOption() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.placeholder = ""; //文本框内显示的占位文字
            _this.action = ""; //上传地址
            _this.required = false; //是否必填
            _this.requiredMessage = ""; //必填提示
            return _this;
        }
        return EditorOption;
    }(BaseOption));

    var Editor = /** @class */ (function () {
        function Editor() {
            this._option = new EditorOption();
            this._config = new AllConfig();
        }
        Editor.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var minheight = this._option.height;
            minheight = minheight.indexOf("px") > 0 ? (Number(minheight.replace("px", "")) - 43) + "px" : this._option.height;
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "  " + (this._option.required ? "dlong_req" : "") + " \"  >\n            <label class=\"dlong_label\" style=\"width:" + this._option.labelWidth + "px;\">" + this._option.label + "</label>\n           <div class=\"dlong_content\" style=\"margin-left:" + this._option.labelWidth + "px\">\n           <div class=\"" + (this._option.disable ? 'dlong_disable' : '') + "\" style=\"width:" + this._option.width + ";height:" + this._option.height + " \"> \n           <textarea autocomplete=\"off\" class=\"dlong_textarea\" type=\"text\" \n              id=\"" + this._option.id + "\" \n              name=\"" + this._option.id + "\"\n              " + (this._option.disable ? 'disabled="disabled"' : "") + "\n              \n              placeholder=\"" + this._option.placeholder + "\"\n              >\n            \n              </textarea>\n              </div>\n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            this._element = element.querySelector("textarea");
            this._element.value = this._option.defaultValue.toString();
            this._editindex = layui.layedit.build(this._element, {
                height: minheight //设置编辑器高度
                ,
                uploadImage: {
                    url: this._option.action //接口url
                    ,
                    type: 'post' //默认post
                }
            });
            this._htmlelement = element;
        };
        Editor.prototype.setValue = function (value) {
            this._option.defaultValue = value;
            this.setOption(this._option);
        };
        Editor.prototype.getValue = function () {
            return layui.layedit.getContent(this._editindex);
        };
        Editor.prototype.getOption = function () {
            this._option.defaultValue = this.getValue();
            return this._option;
        };
        Editor.prototype.getConfig = function () {
            return this._config;
        };
        Editor.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Editor.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Editor;
    }());

    var GridOption = /** @class */ (function () {
        function GridOption() {
            this.columns = [{ span: 6, list: [] }, { span: 6, list: [] }]; //列配置
            this.space = 0; //列间隔
        }
        return GridOption;
    }());

    // type GridObject = {index:number,child:BaseControl};
    var Grid = /** @class */ (function () {
        function Grid() {
            this._option = new GridOption();
            this._config = new AllConfig();
        }
        Grid.prototype.render = function (element, option) {
            this._option = __assign(__assign({}, this._option), option);
            this._child = new Array();
            for (var key in this._config) {
                if (this._option[key] == undefined) {
                    delete this._config[key];
                }
                else {
                    this._config[key].default = this._option[key];
                }
            }
            var optionstr = "";
            for (var i = 0; i < this._option.columns.length; i++) {
                var col = this._option.columns[i];
                optionstr += "  <div class=\"dlong_col layui-col-xs" + col["span"] + " layui-col-sm" + col["span"] + " layui-col-md" + col["span"] + " layui-col-lg" + col["span"] + " \">\n                    <div class=\"dlong_col_list\"></div>\n                </div>";
            }
            var html = "<div class=\"dlong_item " + (this._option.hidden ? "dlong_hidden" : "") + "\"  >\n            \n           <div class=\"dlong_content\">\n                <div class=\"layui-fluid\">\n                <div class=\"layui-row layui-col-space" + this._option.space + "\" id=\"" + this._option.id + "\">\n                    " + optionstr + "\n                    </div>\n                 </div>  \n              </div>\n              </div>\n            ";
            element.innerHTML = html;
            //容器内添加组件
            var elelist = element.querySelectorAll(".dlong_col_list");
            this._child = [];
            this.childArray = [];
            for (var i = 0; i < this._option.columns.length; i++) {
                var col = this._option.columns[i];
                if (!col)
                    break;
                var collist = col.list;
                var childlist = [];
                for (var j = 0; j < collist.length; j++) {
                    var _n = document.createElement("div");
                    _n.className = "dl_widget";
                    elelist[i].appendChild(_n);
                    var child = new dlong[collist[j]["type"]]();
                    child.render(_n, collist[j]);
                    childlist.push(child);
                    this.childArray.push(child);
                }
                this._child.push(childlist);
            }
            this._htmlelement = element;
        };
        Grid.prototype.setValue = function (colmun) {
            if (colmun.index >= this._option.columns.length) {
                console.info("[警告]设置属性值索引超过column长度");
                return;
            }
            var child = this._option.columns[colmun.index].list;
            child.push(colmun.child.getOption());
            this.render(this._htmlelement, this._option);
        };
        Grid.prototype.getValue = function () {
            return this._child;
        };
        Grid.prototype.getOption = function () {
            return this._option;
        };
        Grid.prototype.getConfig = function () {
            return this._config;
        };
        Grid.prototype.setOption = function (option) {
            this.render(this._htmlelement, option);
        };
        Grid.prototype.remove = function () {
            this._element.remove();
            this._htmlelement.innerHTML = "";
        };
        return Grid;
    }());

    var dlong;
    (function (dlong) {
        var input = /** @class */ (function (_super) {
            __extends(input, _super);
            function input() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return input;
        }(Input));
        dlong.input = input;
        var textarea = /** @class */ (function (_super) {
            __extends(textarea, _super);
            function textarea() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return textarea;
        }(TextArea));
        dlong.textarea = textarea;
        var label = /** @class */ (function (_super) {
            __extends(label, _super);
            function label() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return label;
        }(Label));
        dlong.label = label;
        var radio = /** @class */ (function (_super) {
            __extends(radio, _super);
            function radio() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return radio;
        }(Radio));
        dlong.radio = radio;
        var checkbox = /** @class */ (function (_super) {
            __extends(checkbox, _super);
            function checkbox() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return checkbox;
        }(Checkbox));
        dlong.checkbox = checkbox;
        var select = /** @class */ (function (_super) {
            __extends(select, _super);
            function select() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return select;
        }(Select));
        dlong.select = select;
        var date = /** @class */ (function (_super) {
            __extends(date, _super);
            function date() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return date;
        }(Date));
        dlong.date = date;
        var fileupload = /** @class */ (function (_super) {
            __extends(fileupload, _super);
            function fileupload() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return fileupload;
        }(FileUpload));
        dlong.fileupload = fileupload;
        var editor = /** @class */ (function (_super) {
            __extends(editor, _super);
            function editor() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return editor;
        }(Editor));
        dlong.editor = editor;
        var grid = /** @class */ (function (_super) {
            __extends(grid, _super);
            function grid() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            return grid;
        }(Grid));
        dlong.grid = grid;
    })(dlong || (dlong = {}));

    var cacheFormDesgin = /** @class */ (function () {
        function cacheFormDesgin() {
            this.instances = {};
        }
        cacheFormDesgin.prototype.create = function (key, ops) {
            this.instances[key] = ops;
        };
        cacheFormDesgin.prototype.getInstance = function (id) {
            var instance = this.instances[id];
            if (typeof instance === 'undefined') {
                throw new Error("No control instance found with  " + id);
            }
            return instance;
        };
        cacheFormDesgin.prototype.destroy = function (id) {
            delete this.instances[id];
        };
        return cacheFormDesgin;
    }());
    var formDesign = {
        _desgin: new cacheFormDesgin(),
        _currentControl: "default",
        init: function () {
            this._desgin.create("default", dlong);
            this._currentControl = "default";
        },
        changeControl: function (name) {
            this._currentControl = name;
        },
        //注册控件 扩展表单
        register: function (id, pluginoptions) {
            this._desgin.create(id, pluginoptions);
            this.changeControl(id);
        },
        render: function (element, option) {
            var control = this._desgin.getInstance(this._currentControl);
            var fun = control[option["type"]];
            if (!fun) {
                return null;
            }
            var _input = new fun();
            _input.render(element, option);
            return _input;
        }
    };
    formDesign.init();

    return formDesign;

})));
